home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WAXString.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-21  |  4.8 KB  |  162 lines

  1. /*******************************************************************
  2.  *
  3.  * WAXString
  4.  *
  5.  *   A wrapper for ActiveX strings (BSTRs) that combines the
  6.  *   features of WString with those of WBString.
  7.  *
  8.  *   Copyright 1998 by Sybase, Inc.  All rights reserved.
  9.  *
  10.  *******************************************************************/
  11.  
  12. #ifndef _WAXSTRING_HPP_INCLUDED
  13. #define _WAXSTRING_HPP_INCLUDED
  14.  
  15. #ifndef _WNO_PRAGMA_PUSH
  16. #pragma pack(push,8);
  17. #pragma enum int;
  18. #endif
  19.  
  20. #ifndef _WSTRING_HPP_INCLUDED
  21. #include "wstring.hpp"
  22. #endif
  23.  
  24. #ifndef _WOLEBSTR_HPP_INCLUDED
  25. #include "wolebstr.hpp"
  26. #endif
  27.  
  28.  
  29. //
  30. // WAXString
  31. //
  32.  
  33. class WCMCLASS WAXString : public WString {
  34.     WDeclareSubclass( WAXString, WString )
  35.  
  36.     public:
  37.         WAXString();
  38.         WAXString( const WString & str );
  39.         WAXString( const WBString & str );
  40.         WAXString( const WChar *str, WULong numChars=USE_STR_LEN );
  41.         WAXString( WBStr handle, WBool copyHandle,
  42.                    WBool deleteHandle=TRUE );
  43.         WAXString( const WResourceID & id, WModuleHandle modHandle=_ApplicationModule ); 
  44.         WAXString( const WMessageID & id, WModuleHandle modHandle=_ApplicationModule );
  45.  
  46.             ~WAXString();
  47.         
  48.         // Casting operators
  49.         
  50.         operator const WBStr() const { return GetHandle(); }
  51.         operator const WAnsiChar*() const { return GetAnsiText(); }
  52.         operator const WBString() const { return WBString( *this ); }
  53.         
  54.         // = operator
  55.  
  56.         WAXString & operator=( const WAnsiChar *s );
  57.         WAXString & operator=( const WUnicodeChar *s );
  58.             WAXString & operator=( const WString & s );
  59.         WAXString & operator=( const WBString & s );
  60.         
  61.         // += operator
  62.         
  63.         WAXString & operator+=( const WAnsiChar *s );
  64.         WAXString & operator+=( const WUnicodeChar *s );
  65.         WAXString & operator+=( const WString & s );
  66.         WAXString & operator+=( const WBString & s );
  67.         WAXString & operator+=( WAnsiChar a );
  68.         WAXString & operator+=( WUnicodeChar u );
  69.         
  70.         // + operator
  71.         
  72.         WAXString operator+( const WAnsiChar *s );
  73.         WAXString operator+( const WUnicodeChar *s );
  74.         WAXString operator+( const WString & s );
  75.         WAXString operator+( const WBString & s );
  76.         WAXString operator+( WAnsiChar a );
  77.         WAXString operator+( WUnicodeChar u );
  78.         friend WAXString WEXPORT operator+( const WAnsiChar *a, const WAXString & b );
  79.         friend WAXString WEXPORT operator+( const WUnicodeChar *a, const WAXString & b );
  80.         
  81.         // Copy
  82.         //
  83.         //     Copies an arbitrary BSTR.
  84.         
  85.         static WBStr Copy( WBStr handle );
  86.  
  87.         // Create
  88.         //
  89.         //    Create a WAXString from various sources.
  90.         
  91.         WBool Create();
  92.         WBool Create( const WString & str );
  93.         WBool Create( const WBString & str );
  94.         WBool Create( const WChar *str, WULong numChars=USE_STR_LEN );
  95.         WBool Create( WBStr handle, WBool copyHandle,
  96.                       WBool deleteHandle=TRUE );
  97.         WBool Create( const WResourceID & id, WModuleHandle modHandle=_ApplicationModule );
  98.         WBool Create( const WMessageID & id, WModuleHandle modHandle=_ApplicationModule );
  99.  
  100.         // Free
  101.         // 
  102.         //    Frees an arbitrary BSTR.
  103.         
  104.         static void Free( WBStr handle );
  105.         
  106.         // Handle
  107.             //
  108.             //    Set or get as a BSTR.
  109.  
  110.             WBStr GetHandle( WBool copyHandle=FALSE ) const;
  111.             WBool SetHandle( WBStr handle, WBool copyHandle=FALSE,
  112.                          WBool deleteHandle=TRUE );
  113.  
  114.         // Left
  115.         //
  116.         //    Return the n leftmost characters.
  117.         
  118.         WAXString Left( WULong numChars ) const;
  119.         
  120.         // Right
  121.         //
  122.         //    Return the n rightmost characters.
  123.         
  124.         WAXString Right( WULong numChars ) const;
  125.         
  126.             // SetDirty
  127.             //
  128.             //    Called whenever someone has
  129.             //    changed the WString.  We can use this
  130.             //    notification to reset our internal string data.
  131.  
  132.             virtual WBool SetDirty( WBool dirty=TRUE );
  133.         
  134.         // Strip
  135.         //
  136.         //    Return the string trimmed of whitespace.
  137.         
  138.         WAXString Strip( WBool fromBeg=TRUE, WBool fromEnd=TRUE ) const;
  139.         
  140.         // Substring
  141.         //
  142.         //    Return a substring.
  143.         
  144.         WAXString Substring( WULong startAt, WULong numChars=USE_STR_LEN ) const;
  145.         
  146.         
  147.  
  148.     protected:
  149.             virtual WBool PrepareForRead() const;
  150.  
  151.             WBStr         _handle;
  152.             WBool         _deleteHandle;
  153. };
  154.  
  155.  
  156. #ifndef _WNO_PRAGMA_PUSH
  157. #pragma enum pop;
  158. #pragma pack(pop);
  159. #endif
  160.  
  161. #endif // _WAXSTRING_HPP_INCLUDED
  162.